﻿/**************************************************************
 * Copyright Eastmoney Corporation. All rights reserved.
 * 
 * Author: guitao(guitao@eastmoney.com) 
 * Create Date: 2020/6/12 13:32:01
 * Description:
 *          
 * Revision History:
 *      Date         Author               Description
 *              
***************************************************************/

using gt.EventBus.Events;
using System;
using System.Collections.Generic;
using System.Text;

namespace gt.EventBus.Abstractions
{
    public interface IEventBus
    {
        /// <summary>
        /// 事件消息发布
        /// </summary>
        /// <param name="event"></param>
        void Publish(IntegrationEvent @event);
        /// <summary>
        /// 订阅事件
        /// </summary>
        /// <typeparam name="T">事件</typeparam>
        /// <typeparam name="TH">事件处理器</typeparam>
        void Subscribe<T, TH>()
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler<T>;
        /// <summary>
        /// 取消订阅事件
        /// </summary>
        /// <typeparam name="T">事件</typeparam>
        /// <typeparam name="TH">事件处理器</typeparam>
        void Unsubscribe<T, TH>()
            where TH : IIntegrationEventHandler<T>
            where T : IntegrationEvent;
    }
}
